package com.example.reagent_management.ui.history

import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.example.reagent_management.room.entity.HistoryInfo
import com.example.reagent_management.ui.operatedialog.repository.HistoryRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.collect
import javax.inject.Inject

@HiltViewModel
class HistoryViewModel @Inject constructor(private val historyRepository: HistoryRepository) :
    ViewModel() {

    fun historyList(): LiveData<PagingData<HistoryInfo>> {
        return historyRepository.getAllHistory().cachedIn(viewModelScope).asLiveData()
    }
}